DECLARE @xml XML

SET @xml = 
(
    SELECT
        SegmentId  = ISNULL(SegmentId,0)
    ,   DocumentId = ISNULL(DocumentId,0)
    FROM
        SegmentDocument
    WHERE
        DocumentId = @DocumentId
    FOR XML AUTO, ELEMENTS, ROOT('DocumentSegments')
)

SELECT @xml
